var RecentCounter = function() {
    this.queue = [];
};
RecentCounter.prototype.ping = function(t) {
        this.queue.push(t);
    while (this.queue[0] < t - 3000) {
        this.queue.shift();
    }
    return this.queue.length;
};

let arr = new RecentCounter()
console.log(arr.ping(1));
console.log(arr.ping(100));
console.log(arr.ping(3000));
console.log(arr.ping(3002));



